import time
from selenium.webdriver.common.by import By
from units1.Base import Base

class Page(Base):

    iframe_loc=(By.XPATH,'//iframe[starts-with(@id,"x-URS-iframe")]')
    def iframe(self):
        self.frame(self.iframe_loc)

    # 断言账号登录页面
    # yq1_loc = (By.XPATH,'/html/body/div[3]/div[3]/div[1]/div/div[3]/h2')
    # def yq1(self):
    #     return self.text(self.yq1_loc)

    # 输入账号
    user_loc = (By.NAME, 'email')
    def user(self):
        self.send_keys(self.user_loc,'kyt13103053968')
    # 输入密码
    pwd_loc=(By.NAME,'password')
    def pwd(self):
        self.send_keys(self.pwd_loc,'13103053968123Aa')
    # 点击登录
    login_loc=(By.XPATH,'//*[@id="dologin"]')
    def login(self):
        self.click(self.login_loc)
    # 点击写信
    xie_loc=(By.XPATH,'//*[@id="_mail_component_98_98"]/span[1]/b')
    def xie(self):
        self.click(self.xie_loc)
    # 收件人
    shou_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[1]/div[1]/div/div[2]/div/input')
    def shou(self):
        self.send_keys(self.shou_loc,'2440154941@qq.com')
    # 主题
    zhuti_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input')
    def zhuti(self):
            self.send_keys(self.zhuti_loc, '啦啦啦啦')
    # 发送按钮
    fsbtn_loc = (By.CLASS_NAME,'nui-btn-text')
    def fs(self):
        self.click(self.fsbtn_loc)

    # 逻辑
    def luoji_01_login(self):
        self.open_url('https://www.126.com/')
        self.iframe()
        # print(self.yq1())
        # assert '账号登录' == self.yq1()
        self.user()
        self.pwd()
        self.login()
        self.frame_uncon()
        time.sleep(3)
        self.xie()
        self.shou()
        self.zhuti()
        self.fs()
        time.sleep(3)